from flask import request, redirect, render_template, url_for
from flask.views import View


class TemplateView(View):
    template_name = None
    methods = ['GET', 'POST']

    def dispatch_request(self, *args, **kwargs):
        return getattr(self, request.method.lower())(*args, **kwargs)

    def get_context_data(self):
        context = {}
        return context

    def get(self, *args, **kwargs):
        context = self.get_context_data()
        return render_template(self.template_name, **context)

    def post(self, *args, **kwargs):
        return '/'


class ActionView(View):
    methods = ['GET', 'POST']

    def dispatch_request(self, *args, **kwargs):
        return getattr(self, request.method.lower())(*args, **kwargs)